using System;
using System.Collections.Generic;
using System.Text;

namespace SymAutomate.RawCommand
{
    /// <summary>
    /// Error Numbers 700-719; Reference file ErrorNumbers.txt for more information.
    /// 700 Error: Required argument 'rawcommandtype' missing or invalid. Use /h switch for help.
    /// 701 Error: Required argument 'rawcommandparam' missing. Use /h switch for help.
    /// 702 Error: Argument 'rawcommandparam' invalid format. Use /h switch for help.
    /// </summary>
    class Parameters : ParametersBase
    {
        #region Class Variables and Access Methods
        private string __RawCommandType;
        private RawCommandParameter __RawCommandParameter;

        public string RawCommandType { get { return __RawCommandType; } }
        public RawCommandParameter RawCommandParameter { get { return __RawCommandParameter; } }
        #endregion

        public Parameters(ConsoleArguments _ConsoleArguments, List<ConsoleHelp> _ConsoleHelpList)
            : base(_ConsoleArguments, _ConsoleHelpList)
        {
            //defaults
            __RawCommandType = string.Empty;
            __RawCommandParameter = new RawCommandParameter();

            //save from command line arguments
            if (_ConsoleArguments.ArgumentCollection.Contains("rawcommandtype")) __RawCommandType = _ConsoleArguments.ArgumentCollection["rawcommandtype"].ToString().ToLower();
            if (_ConsoleArguments.ArgumentCollection.Contains("rawcommandparam")) __RawCommandParameter = new RawCommandParameter(_ConsoleArguments.ArgumentCollection["rawcommandparam"].ToString());

            //perform argument error checking
            if (string.IsNullOrEmpty(__RawCommandType) || (__RawCommandType != "aix" && __RawCommandType != "symop" && __RawCommandType != "sym"))
                throw new ReturnException("700 Error: Required argument 'rawcommandtype' missing or invalid. Use /h switch for help.");
            if (string.IsNullOrEmpty(__RawCommandParameter.RawCommand))
                throw new ReturnException("701 Error: Required argument 'rawcommandparam' missing. Use /h switch for help.");
            if (!__RawCommandParameter.ParseRawCommand())
                throw new ReturnException("702 Error: Argument 'rawcommandparam' invalid format. Use /h switch for help.");
        }
    }
}
